package com.mybatisplus.demo;

import com.mybatisplus.demo.mapper.UserMapper2;
import com.mybatisplus.demo.model.MyPage;
import com.mybatisplus.demo.model.ParamSome;
import com.mybatisplus.demo.model.User;
import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.Date;
import java.util.List;


@RestController
@RequestMapping("/test")
public class TestController {


    public static void main(String[] args) {
      //  new  TimingWheel();
    }

    @Autowired
    private UserMapper2 userMapper2;


    //http://localhost:8088/demo/test/hello
    @GetMapping("/hello")
    public String hello() {
        return "hello" + (new Date()).toString();
    }


    //http://localhost:8888/demo/test/selectAll
    @GetMapping("/selectAll")
    public String queryOne() {
        System.out.println(("----- selectAll method test ------"));
        List<User> userList = userMapper2.selectList(null);
        Assert.assertEquals(5, userList.size());
        userList.forEach(System.out::println);
        return null;
    }


    //http://localhost:8088/demo/test/hello
    @GetMapping("/mySelectPage")
    public String mySelectPage() {
        MyPage<User> myPage = new MyPage<User>(1, 5).setSelectInt(20).setSelectStr("Jack");
        ParamSome paramSome = new ParamSome(20, "Jack");
        MyPage<User> userMyPage = userMapper2.mySelectPage(myPage, paramSome);
        // assertThat(myPage).isSameAs(userMyPage);
        System.out.println("hello :" + null);
        System.out.println("总条数 -------------> {}" + userMyPage.getTotal());
        System.out.println("当前页数 -------------> {}" + userMyPage.getCurrent());
        System.out.println("当前每页显示数 -------------> {}" + userMyPage.getSize());

        return "mySelectPage" + (new Date()).toString();
    }


}
